import { observable, action, computed, autorun } from 'mobx';
import { getUserInfo } from "../api/api";

export default class User {
  @observable
  mytimer = {
    timer: 10,
    type: 'dfsfsdfdsf',
  };
  @observable
  info = {
    account: '',
    img: ''
  }
  // @autorun(() => {
  //   console.log(this.mytimer.timer.get());
  // })
  @action
  aa() {
    return new Promise((resolve) => {
      if (this.mytimer.timer % 2) {
        resolve('奇数');
      } else {
        resolve('偶数');
      }
    });
  }
  @action
  async resetTime() {
    this.mytimer.timer += 1;
    this.mytimer.type = await this.aa();
  }
  @action
  async getUserInfo(account) {
    const res = await getUserInfo({account});
    this.info = res.data
  }
  @action
  delUserInfo(account) {
    this.info = {}
  }
  @computed get bool() {
    return ((this.mytimer.timer) % 3);
  }
}
